<!DOCTYPE html>  
<html>  
<head>  
<meta charset="utf-8">  
<title>Downloader Example</title>  
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript">  
// 扩展API加载完毕后调用onPlusReady回调函数  
//document.addEventListener( "plusready", onPlusReady, false );  
var r = null;  
// 扩展API加载完毕，现在可以正常调用扩展API  
 
// 创建下载任务  
function createDownload() {
var dtask = plus.downloader.createDownload( "http://insure.unair.cn/./upload/1508985531-9171.jpg", {},   function ( d, status ) {  
// 下载完成  
if ( status == 200 ) {  
alert( "Download success: " + d.filename );  
} else {  
 alert( "Download failed: " + status );  
}    
},function(){
	alert(22)
}
);
//dtask.addEventListener( "statechanged", onStateChanged, false );  
dtask.start();  
}

function read() {
plus.io.resolveLocalFileSystemURL( "_downloads/1508985531-9171.jpg", function( entry ) {  
// 可通过entry对象操作test.html文件   
entry.file( function(file){  
var fileReader = new plus.io.FileReader();  
//alert(JSON.stringify(file['fullPath']));
var item = "<img src='" +file['fullPath']+ "' />";
$("#aaa").append(item)
//alert("getFile:" + JSON.stringify(file));  
//fileReader.readAsDataURL(file, '');  
//fileReader.onloadend = function(evt) {  
//alert("11" + evt);  
//alert("evt.target" + evt.target);  
//alert(evt.target.result);  
//}  
//alert(file.size + '--' + file.name);  
} );  
}, function ( e ) {  
alert( "Resolve file URL failed: " + e.message );  
} );  
}
</script>  
</head>  
<body>  
	<div id="" style="height: 200px;">
		
	</div>
<input id="download" type="button" value="Create download task" onclick="createDownload();">下载</input>
<input type="button" name="search" id="search" value="查看" onclick="read()" />
<div id="aaa"></div>
</body>  
</html>  